
package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.service.UmsMemberGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"memberGroup"})
@Api(
        tags = {"UmsMemberGroupController"}
)
public class UmsMemberGroupController {
    private static final Logger log = LoggerFactory.getLogger(UmsMemberGroupController.class);
    @Autowired
    UmsMemberGroupService umsMemberGroupService;

    public UmsMemberGroupController() {
    }

    @ApiOperation("社区列表")
    @RequestMapping(
            value = {"/findCommunity"},
            method = {RequestMethod.GET}
    )
    @ResponseBody
    public CommonResult<CommonPage<Map>> findCommunity(@RequestParam(value = "countyCode",required = true) String countyCode) {
        List<Map> communities = this.umsMemberGroupService.findCommunity(countyCode);
        return CommonResult.success(CommonPage.restPage(communities));
    }

    @ApiOperation("组列表")
    @RequestMapping(
            value = {"/findGroups"},
            method = {RequestMethod.GET}
    )
    @ResponseBody
    public CommonResult<CommonPage<Map>> findGroups(@RequestParam(value = "communityId",required = true) Long communityId) {
        List<Map> groups = this.umsMemberGroupService.findGroups(communityId);
        return CommonResult.success(CommonPage.restPage(groups));
    }

    @ApiOperation("人员列表")
    @RequestMapping(
            value = {"/findMembers"},
            method = {RequestMethod.GET}
    )
    @ResponseBody
    public CommonResult<CommonPage<Map>> findMembers(@RequestParam(value = "communityId",required = true) Long communityId, @RequestParam(value = "groupCode",required = true) String groupCode) {
        List<Map> members = this.umsMemberGroupService.findMembers(communityId, groupCode);
        return CommonResult.success(CommonPage.restPage(members));
    }
}